home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Multimedia / Sound / PlayerPRO 4.6 Dev.Kit / MADH Library 4.6 / MacOS Examples / Example.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-23  |  3.7 KB  |  144 lines  |  [TEXT/CWIE]

  1. /********************************************************/
  2. /*
  3.     Player PRO 4.5.2 -- Music Driver EXAMPLE
  4.  
  5.     Library Version 4.02
  6.  
  7.     To use with Think C & CodeWarrior
  8.  
  9.     Antoine ROSSET
  10.     16 Tranchees
  11.     1206 GENEVA
  12.     SWITZERLAND
  13.     
  14.     FAX: (+41 22) 346 11 97
  15.     PHONE: (+41 89) 203 74 62
  16.     Email: rosset@dial.eunet.ch
  17. */
  18. /********************************************************/
  19.  
  20. #include "RDriver.h"            // Mad Driver functions & globals
  21.  
  22. void OSType2Ptr( OSType type, Ptr str)
  23. {
  24.     short i;
  25.     
  26.     BlockMove( &type, str, 4);
  27.     str[ 4] = 0;
  28. }
  29.  
  30. /*****************************/
  31. /****** MAIN FUNCTION ********/
  32. /*****************************/
  33.  
  34. void main( void)
  35. {
  36. Boolean                    End = false;
  37. MADDriverRec        *MADDriver;
  38. MADMusic                *MADMusic;
  39.  
  40. /***************                    ****************/
  41. /******          Toolbox Initialization      **********/
  42. /***************                    ****************/
  43.  
  44. InitGraf( &qd.thePort);
  45. InitFonts();
  46. InitWindows();
  47. InitMenus();
  48. TEInit();
  49. InitDialogs(0L);
  50. InitCursor();
  51. MaxApplZone();
  52. MoreMasters();
  53.  
  54. /*******************************************************************************************/
  55. /****** MAD Library Initialisation : choose the best driver for the current hardware  ******/
  56. /******                                                                                  ******/
  57. /****** Standard initialization with 4 channels...                                      ******/
  58. /*******************************************************************************************/
  59.  
  60. {
  61. MADDriverSettings    init;
  62.  
  63.  
  64. /*
  65. MANUAL DRIVER CONFIGURATION, by example:
  66.  
  67. init.numChn                = 4;
  68. init.outPutBits         = 8;
  69. init.outPutRate            = rate22khz;
  70. init.outPutMode            = StereoOutPut;
  71. init.driverMode            = SoundManagerDriver;
  72. init.antiAliasing        = false;
  73. init.repeatMusic        = false;
  74. init.Interpolation        = false;
  75. init.MicroDelay            = false;
  76. init.MicroDelaySize     = 35;
  77. init.surround             = false;
  78. init.sysMemory            = false;
  79. init.Reverb                = false;
  80. init.ReverbSize            = 45;
  81. init.ReverbStrength        = 60;
  82. init.ReverbStrength        = 60;
  83. init.TickRemover        = false;
  84. */
  85.  
  86. /* or AUTOMATIC DRIVER CONFIGURATION FOR CURRENT MAC HARDWARE*/
  87. MADGetBestDriver( &init);
  88.  
  89. if( MADInitLibrary( "Plugs", init.sysMemory) != noErr) DebugStr("\pSmall Problem...");
  90. if( MADCreateDriver( &init, &MADDriver) != noErr) DebugStr("\pSmall Problem...");
  91. }
  92. /*********************************/
  93. /*********************************/
  94. /*********************************/
  95.  
  96. /****** Open a music file via Plugs ********/
  97. while( End == false)
  98. {
  99.     StandardFileReply    reply;
  100.     SFTypeList            aType;
  101.     
  102.     FlushEvents( everyEvent, 0);
  103.     
  104.     StandardGetFile( 0L, -1, aType, &reply);
  105.     
  106.     if( !reply.sfGood) End = true;
  107.     else
  108.     {
  109.         char type[ 5];
  110.         
  111.         OSType2Ptr( reply.sfType, type);
  112.         
  113.         if( MADPlugAvailable( type))        // Is available a plug to open this file?
  114.         {
  115.             if( MADLoadMusicFSpFile( &MADMusic, type, &reply.sfFile) == noErr)        // Load this music with help of Plugs
  116.                                                                                     // in application folder, in 'Plugs' folder or internal resources
  117.             {
  118.                 MADAttachDriverToMusic( MADDriver, MADMusic);
  119.                 
  120.                 MADStartDriver( MADDriver);                // Turn interrupt driver function ON
  121.                 MADPlayMusic( MADDriver);                    // Read the current partition in memory
  122.                 
  123.                 while( !Button())
  124.                 {
  125.                     /// Do what you want here....
  126.                     /// Bla bla...
  127.                     /// By example:    Run your realtime 3D game
  128.                     ///             with 24bit texture mapping...
  129.                     
  130.                     long    fT, cT;
  131.                     
  132.                     MADGetMusicStatus( MADDriver, &fT, &cT);    // Some infos about current music
  133.                 }
  134.                 MADStopMusic( MADDriver);                    // Stop reading current partition
  135.                 MADStopDriver( MADDriver);                // Stop driver interrupt function
  136.                 MADDisposeMusic( &MADMusic);            // Dispose the current music
  137.             }
  138.         }
  139.     }
  140. }
  141. MADDisposeDriver( MADDriver);                        // Dispose music driver
  142. MADDisposeLibrary();                    // Close music library
  143. FlushEvents( everyEvent, 0);            // Kill your events and byebye...
  144. }